<!DOCTYPE html>
<html>
    <head>
        <script src="js/vue.js"></script>
        <script src="js/vuex.js"></script>
    </head>
    <body>
        <div id="app">
            <button @click="mut">查看mutations方式接收参数</button>
            <button @click="act">查看actions方式接收参数</button>
        </div>
        <script>
            var store = new Vuex.Store({
                state : {
                    name : '张三',
                    age : 38,
                    gender : '男'
                },
                mutations : {
                    test(state) { console.log(state) }
                },
                actions : {
                    test(context,param) { console.log(context,param) }
                }
            })

            var vm = new Vue({
                el : '#app',
                store ,
                methods : {
                    mut() { this.$store.commit('test') },
                    act() { 
                        //this.$store.dispatch('test','这里是要传递的参数') 
                        this.$store.dispatch({type:'test',name:'这是通过对象传递的参数'}) 
                    }
                }
            })

        </script>
    </body>
</html>